<template>
  <el-form ref="form" :model="form" label-width="80px" class="login-box">
    <h3 class="login-title">欢迎登录</h3>
    <el-form-item label="账号" style="letter-spacing: 1em;">
      <el-input v-model="form.username"></el-input>
    </el-form-item>
    <el-form-item label="密码" style="letter-spacing: 1em;">
      <el-input placeholder="请输入密码" v-model="form.password" show-password></el-input>
    </el-form-item>
    <el-form-item class="button-box">
      <el-button type="primary" @click="onSubmit" style="margin-right:35px;">登录</el-button>
      <el-button style="margin-right:35px;">取消</el-button>
    </el-form-item>
  </el-form>
</template>

<script>
export default {
  data() {
    return {
      form: {
        username: "",
        password: ""
      }
    };
  },
  methods: {
    onSubmit() {
      this.$axios
        .post("/permit/login", JSON.stringify(this.form))
        .then((response) => {
          console.log(response);
          this.$router.replace("/index");
        })
        .catch(function(error) {
          console.log(error);
        });
    }
  }
};
</script>

<style scoped>
.login-box {
  border: 1px solid #dcdfe6;
  width: 320px;
  margin: 120px auto;
  padding: 25px 25px 5px 25px;
  border-radius: 5px;
  -webkit-border-radius: 5px;
  -moz-border-radius: 5px;
  box-shadow: 0 0 25px #909399;
}
.login-title {
  text-align: center;
  margin: 0 auto 40px auto;
  color: #303133;
}
</style>